<?php
//namespace Login\Model;

require_once '\Config\DBSettings.php';

class DBConnection{
	private $m_mysqli = NULL;
	
	public function Connect()
	{
		$this->m_mysqli = new mysqli(DBSettings::DBHOST, DBSettings::DBUSER, DBSettings::DBPASS, DBSettings::DATABASE);
		
		$this->m_mysqli->set_charset("utf8");
		
		if($this->m_mysqli->connect_errno){
			echo "Connect failed: $this->m_mysqli->connect_error";
	        return false;
		}
		return true;
	}
	public function Close()
	{
		$this->m_mysqli->close();
	}
	
	public function Prepare($sql) {
		$stmt = $this->m_mysqli->prepare($sql);
		if ($stmt === FALSE) {
				echo "prepare of '$sql' failed " . $this->m_mysqli->error;
			return false;
		}
		return $stmt;
	}
}
